home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / pwrbat23.zip / CALC.PWR < prev    next >
Text File  |  1996-05-09  |  12KB  |  352 lines

  1.   Variable    Work,255
  2.   Variable    Month,2
  3.   Variable    Day,2
  4.   Variable    Year,4
  5.   Variable    Time,11
  6.   Variable    CurClr,3
  7.   Variable    Normal,1,1
  8.   Variable    On,1,1
  9.   Variable    Off,1,0
  10.   Variable    Zeros,18,'000000000000000000'
  11.   Variable    Spaces,18,'                  '
  12.   Variable    Cmds1,100,'224Number Of Decimals 2332   224Memory Cell           233Esc224 Exit'
  13.   Variable    Cmds2,100,'233+224  Add  233-224 Subtract  233*224 Multiply   233/224 Divide  233F1224 Decimals'
  14.   Variable    Cmds3,100,'233F2224 Clr Total   233F3224 Clr Memory  233F4224 Recall Memory'
  15.   Variable    Cmds4,100,'233F5224 Add to Mem  233F6224 Sub fr Mem  233F7224 Stor to Mem '
  16.   Variable    Plus,1,#43
  17.   Variable    Minus,1,#45
  18.   Variable    Mult,1,#42
  19.   Variable    Div,1,#47
  20.   Variable    F1,1,#59
  21.   Variable    F2,1,#60
  22.   Variable    F3,1,#61
  23.   Variable    F4,1,#62
  24.   Variable    F5,1,#63
  25.   Variable    F6,1,#64
  26.   Variable    F7,1,#65
  27.   Variable    Esc,1,#27
  28.  
  29.   Variable    Mem1,18,0
  30.   Variable    Mem2,18,0
  31.   Variable    Mem3,18,0
  32.   Variable    Mem4,18,0
  33.   Variable    Total,18,0
  34.   Variable    Entry,18,0
  35.   Variable    RtnCode,2
  36.   Variable    NumDecs,2,2
  37.   Variable    CtrLgth,2
  38.   Variable    DecLoc,2
  39.   Variable    DecToAdd,2
  40.   Variable    Func,1,' '
  41.   Variable    Spec,1
  42.  
  43.   ?Color      Work,Work,CurClr
  44.   Cursor      Off
  45.   EnhanClr    On
  46.   Clear       135,,'░'
  47.   Box1        1,1,57,3,228                      ;Title box
  48.   Box1        1,20,57,25,228                    ;msg box at bottom
  49.   Box1        58,1,80,25,240                    ;"tape" box
  50.   Box1        3,5,27,7,158                      ;mem 1 box
  51.   Box1        31,5,55,7,158                     ;mem 2 box
  52.   Box1        3,10,27,12,158                    ;mem 3 box
  53.   Box1        31,10,55,12,158                   ;mem 4 box
  54.   Box1        18,15,40,17,160                   ;entry box
  55.   WriteAt     17,2,'The PowerBatch Calculator',228
  56.   ?Date       Work,Month,Day,Year
  57.   Concat      Work,Month,'/',Day,'/',Year
  58.   WriteAt     3,3,Work,228
  59.   WriteAt     11,5,'Memory 1',159
  60.   WriteAt     39,5,'Memory 2',159
  61.   WriteAt     11,10,'Memory 3',159
  62.   WriteAt     39,10,'Memory 4',159
  63.   WriteAt     27,15,'Entry',160
  64.   WriteAt     3,21,Cmds1
  65.   WriteAt     3,22,Cmds2
  66.   WriteAt     3,23,Cmds3
  67.   WriteAt     3,24,Cmds4
  68.   GoTo        DispMem
  69.  
  70. Label     NextCalc
  71.   SetVar      DecToAdd,NumDecs
  72.   LocStr      '.',Entry,1,DecLoc                ;force a decimal
  73.   Compare     DecLoc,0,Dec1
  74.   Concat      Entry,'.'
  75.   LocStr      '.',Entry,1,DecLoc
  76. Label         Dec1
  77.   Length      CtrLgth,Entry                     ;align the decimal
  78.   Subtract    CtrLgth,DecLoc
  79.   Subtract    DecToAdd,CtrLgth
  80.   SetVar      Work,''
  81.   MidString   Work,Zeros,1,DecToAdd             ;get some zeros
  82.   Concat      Entry,Work                        ;add to units pos
  83.   Length      CtrLgth,Entry                     ;left space fill
  84.   SetVar      DecToAdd,19
  85.   Subtract    DecToAdd,CtrLgth
  86.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  87.   Concat      Work,Work,Entry,Func              ;add to high order
  88.   Window1     58,1,80,25,240                    ;open our tape window
  89.   GoToXy      1,23                              ;  so we scroll
  90.   WriteLine   Work,240
  91.  
  92. Label     PrtTotal
  93.   SetVar      DecToAdd,NumDecs
  94.   LocStr      '.',Total,1,DecLoc                  ;force a decimal
  95.   Compare     DecLoc,0,TotDec
  96.   Concat      Total,'.'
  97.   LocStr      '.',Total,1,DecLoc
  98. Label     TotDec
  99.   Length      CtrLgth,Total                     ;align the decimal
  100.   Subtract    CtrLgth,DecLoc
  101.   Subtract    DecToAdd,CtrLgth
  102.   SetVar      Work,''
  103.   MidString   Work,Zeros,1,DecToAdd             ;get some zeros
  104.   Concat      Total,Work                        ;add to units pos
  105.   Length      CtrLgth,Total                     ;left space fill
  106.   SetVar      DecToAdd,19
  107.   Subtract    DecToAdd,CtrLgth
  108.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  109.   Concat      Work,Work,Total,'='               ;add to high order
  110.   Window1     58,1,80,25,240                    ;open our tape window
  111.   GoToXy      1,23                              ;  so we scroll
  112.   WriteLine   Work,240
  113.   Window0     1,1,80,25                         ;full screen
  114.  
  115. Label     DispMem
  116.   Length      CtrLgth,Mem1                      ;left space fill
  117.   SetVar      DecToAdd,20
  118.   Subtract    DecToAdd,CtrLgth
  119.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  120.   Concat      Work,Work,Mem1,' '               ;add to high order
  121.   WriteAt     4,6,Work,154
  122.   Length      CtrLgth,Mem2                     ;left space fill
  123.   SetVar      DecToAdd,20
  124.   Subtract    DecToAdd,CtrLgth
  125.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  126.   Concat      Work,Work,Mem2,' '               ;add to high order
  127.   WriteAt     32,6,Work,154
  128.   Length      CtrLgth,Mem3                     ;left space fill
  129.   SetVar      DecToAdd,20
  130.   Subtract    DecToAdd,CtrLgth
  131.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  132.   Concat      Work,Work,Mem3,' '               ;add to high order
  133.   WriteAt     4,11,Work,154
  134.   Length      CtrLgth,Mem4                     ;left space fill
  135.   SetVar      DecToAdd,20
  136.   Subtract    DecToAdd,CtrLgth
  137.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  138.   Concat      Work,Work,Mem4,' '               ;add to high order
  139.   WriteAt     32,11,Work,154
  140.  
  141. Label     GetFunc
  142.   ClearBox    18,15,40,17,160
  143. Label     ShowTime
  144.   ?Time       Time                              ;get curr time
  145.   Cursor      Off
  146.   WriteAt     45,3,Time,228                     ;disp time
  147.   GoToXY      19,16
  148.   Cursor      Normal
  149.   Color       160
  150.   ReadKey     Func,Spec,1                       ;get our math function
  151.   Compare     Func,'',,,ShowTime                ;did we time out
  152.   Compare     Spec,'0',FuncKey                  ;was the key a special key
  153.   Compare     Func,Esc,,,EndPgm                 ;end the pgm
  154.   Compare     Func,Plus,,,CalcAdd               ;check the functions
  155.   Compare     Func,Minus,,,CalcMinus
  156.   Compare     Func,Mult,,,CalcMult
  157.   Compare     Func,Div,,,CalcDiv
  158.   Cursor      Off                               ;if we get here, invalid key
  159.   GoTo        GetFunc
  160. Label     FuncKey                               ;special key was entered
  161.   Compare     Func,F1,,,SetDecimals
  162.   Compare     Func,F2,,,ClearTot
  163.   Compare     Func,F3,,,ClearMem
  164.   Compare     Func,F4,,,RecallMem
  165.   Compare     Func,F5,,,AddMem
  166.   Compare     Func,F6,,,SubMem
  167.   Compare     Func,F7,,,StoreMem
  168.   GoTo        GetFunc
  169.  
  170. Label     CalcAdd
  171.   ReadStr     Entry
  172.   Add         Total,Entry,RtnCode,NumDecs       ;add to the total
  173.   Compare     RtnCode,0,,NextCalc,NextCalc
  174.   GoTo        MathErr
  175.  
  176. Label     CalcMinus
  177.   ReadStr     Entry
  178.   Subtract    Total,Entry,RtnCode,NumDecs       ;sub from the total
  179.   Compare     RtnCode,0,,NextCalc,NextCalc
  180.   GoTo        MathErr
  181.  
  182. Label     CalcMult
  183.   ReadStr     Entry
  184.   Multiply    Total,Entry,RtnCode,NumDecs       ;multiply total by entry
  185.   Compare     RtnCode,0,,NextCalc,NextCalc
  186.   GoTo        MathErr
  187.  
  188. Label     CalcDiv
  189.   ReadStr     Entry
  190.   Divide      Total,Entry,RtnCode,NumDecs       ;divide total by entry
  191.   Compare     RtnCode,0,,NextCalc,NextCalc
  192.   GoTo        MathErr
  193.  
  194. Label     SetDecimals
  195.   Cursor      Normal
  196.   Color       224
  197.   GoToXY      22,21                             ;find out how many decimals
  198.   Color       228
  199.   ReadStr     NumDecs
  200.   Cursor      Off
  201.   GoTo        GetFunc
  202.  
  203. Label     ClearTot
  204.   SetVar      Total,0
  205.   GoTo        PrtTotal
  206.  
  207. Label     ClearMem
  208.   SetVar      Mem1,0
  209.   SetVar      Mem2,0
  210.   SetVar      Mem3,0
  211.   SetVar      Mem4,0
  212.   GoTo        DispMem
  213.  
  214. Label     RecallMem
  215.   GoToXy      38,21
  216.   Color       228
  217.   ReadKey     Func                              ;which memory counter
  218.   Compare     Func,1,TryMRec2,GetFunc
  219.   SetVar      Total,0
  220.   SetVar      Entry,0
  221.   SetVar      Func,'R'                          ;so it shows as recall
  222.   SetVar      Entry,Mem1
  223.   Add         Total,Entry,RtnCode,NumDecs
  224.   Compare     RtnCode,0,,,NextCalc